<template>
  <v-col>
    <v-row justify="center">
      <v-card>
        <v-card-title>Welcome you --- {{ getUser }}</v-card-title>
        <v-card-text>
          Auth passed
        </v-card-text>
        <v-card-actions>
          <v-btn text @click="doLogout">Logout</v-btn>
        </v-card-actions>
      </v-card>
    </v-row>
  </v-col>
</template>

<script>
export default {
  name: "Welcome",
  computed: {
    getUser() {
      return this.$store.getters.getUser.username
    }
  },
  methods:{
    doLogout(){
      this.axios.post('/logout').then((resp) => {
        let code=resp.data.code;
        if(code===200){
          let data=resp.data;
          alert(data.msg)
          //清除
          //todo 先路由再移除否则会报错
          this.$router.push('/login')
          this.$store.commit('REMOVE_INFO');
        }
      })
    }
  }
}
</script>

<style scoped>

</style>